﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Reviewer.Entities
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "PEGI"), DataContract(Namespace = "Reviewer.Entities")]
    public sealed class PEGIRating : IExtensibleDataObject
    {
        public static bool operator ==(PEGIRating item1, PEGIRating item2)
        {
            // If both are null, or both are same instance, return true.
            if (System.Object.ReferenceEquals(item1, item2))
            {
                return true;
            }

            // If one is null, but not both, return false.
            if (((object)item1 == null) || ((object)item2 == null))
            {
                return false;
            }

            return item1.Equals(item2);
        }
        public static bool operator !=(PEGIRating item1, PEGIRating item2)
        {
            return !(item1 == item2);
        }

        [DataMember(IsRequired = true)]
        public Guid GameId { get; set; }
        [DataMember(IsRequired = true)]
        public int Format { get; set; }
        [DataMember(IsRequired = true)]
        public int AgeRating { get; set; }
        [DataMember]
        public bool IsRatedBadLanguage { get; set; }
        public bool IsRatedDiscrimination { get; set; }
        public bool IsRatedDrugs { get; set; }
        public bool IsRatedFear { get; set; }
        public bool IsRatedGambling { get; set; }
        public bool IsRatedSex { get; set; }
        public bool IsRatedViolence { get; set; }
        public bool IsRatedOnline { get; set; }

        public override bool Equals(object obj)
        {
            PEGIRating second = obj as PEGIRating;
            if (second != null)
            {
                return this.GameId.Equals(second.GameId)
                    && this.Format.Equals(second.Format)
                    && this.AgeRating.Equals(second.AgeRating)
                    && this.IsRatedBadLanguage.Equals(second.IsRatedBadLanguage)
                    && this.IsRatedDiscrimination.Equals(second.IsRatedDiscrimination)
                    && this.IsRatedDrugs.Equals(second.IsRatedDrugs)
                    && this.IsRatedFear.Equals(second.IsRatedFear)
                    && this.IsRatedGambling.Equals(second.IsRatedGambling)
                    && this.IsRatedSex.Equals(second.IsRatedSex)
                    && this.IsRatedViolence.Equals(second.IsRatedViolence)
                    && this.IsRatedOnline.Equals(second.IsRatedOnline);
            }
            return false;
        }

        public override int GetHashCode()
        {
            return this.GameId.GetHashCode();
        }

        #region IExtensibleDataObject PEGIRating
        ExtensionDataObject IExtensibleDataObject.ExtensionData { get; set; }
        #endregion
    }
}
